package org.fuxia.im.common;

import java.awt.Color;
import java.awt.Component;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JCheckBox;
import javax.swing.JList;

import org.fuxia.im.common.MyListCellModel.ShowUser;

public class MyListCellRender extends DefaultListCellRenderer {

	private static final long serialVersionUID = 1L;

	@Override
	public Component getListCellRendererComponent(JList<?> list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		ShowUser currentUser = (ShowUser)value ;
		JCheckBox newRender = new JCheckBox() ;
		Color c = newRender.getBackground() ;
		if(isSelected) {
			newRender.setBackground(Color.GRAY) ;
		}else {
			newRender.setBackground(c);
		}
		newRender.setSelected(currentUser.isSelected()) ;
		newRender.setText(currentUser.getNickName());
		return newRender ;
	}
	
}
